import {
    reqCategoryList,reqGetBannerList, reqGetFloorList
} from "@/api";

const state = {
    // 三级联动数据
    categoryList: [],
    // 轮播图数据
    bannerList:[],
    // floor组件数据
    floorList:[]
};
const mutations = {
    GETCATEGORYLIST(state, categoryList) {
        state.categoryList = categoryList
    },
    GETBANNERLIST(state,bannerList){
        // console.log('获取数据')
        state.bannerList = bannerList
    },
    GETFLOORLIST(state,floorList){
        state.floorList = floorList
    }
};
const actions = {
    // 获取三级分类数据
    async getCategoryList({commit}) {
        
        let result = await reqCategoryList();
        // console.log(result.data)
        if (result.code === 200) {
            commit('GETCATEGORYLIST', result.data)
        }
    },
    // 获取banner轮播图
    async getBannerList({commit}){
        // console.log('发送请求')
        let result = await reqGetBannerList()
        if(result.code === 200){
            commit('GETBANNERLIST',result.data)
        }
    },
    // 获取floor数据
    async reqGetFloorList({commit}){
       let result = await reqGetFloorList()
       if(result.code === 200){
          commit('GETFLOORLIST',result.data)
       }
    }
};
const getters = {}

export default {
    state,
    mutations,
    actions,
    getters
}